import Vue from 'vue'
import Router from 'vue-router'
import Home from './pages/home'
import Index from './pages/index'
import Product from './pages/product'
import Detail from './pages/detail'
import Cart from './pages/cart'
import Order from './pages/order'
import OrderConfirm from './pages/orderConfirm'
import OrderList from './pages/orderList'
import OrderPay from './pages/orderPay'
import Alipay from './pages/alipay'

//Vue.use加载插件的语法
Vue.use(Router);

//export default导出
export default new Router({
    routes:[
        {
            //定义一个home路由，包括三个子路由，每个父路由都可以被子路由复用
            path:'/',
            name:'home',
            component: Home,
            children:[
                {
                    path:'/index',
                    name:'index',
                    component:Index,
                },
                {
                    path:'/product/:id',
                    name:'product',
                    component:Product,
                },
                {
                    path:'/detail',
                    name:'detail',
                    component:Detail,
                }
            ]
        },
        //定义购物车路由
        {
            path: '/cart',
            name:'cart',
            component: Cart
        },
        //定义订单路由
        {
            path: '/order',
            name:'order',
            component: Order,
            children:[
                {
                    //这里不需要要加 /
                    path: 'list',
                    name:'order-list',
                    component: OrderList,
                },
                {
                    path: 'confirm',
                    name:'order-confirm',
                    component: OrderConfirm,
                },
                {
                    path: 'pay',
                    name:'order-pay',
                    component: OrderPay,
                },
                {
                    path:'alipay',
                    name:'alipay',
                    component:Alipay,
                },
            ]
        },
    ]
});
